package follow.juc.beautyconcurrent;

import jdk.nashorn.internal.codegen.CompilerConstants;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallTask implements Callable {
    @Override
    public String call() throws Exception {
        return "Java";
    }

    public static void main(String[] args) {
        FutureTask<String> futureTask = new FutureTask<String>(new CallTask());
        Thread t1 = new Thread(futureTask);

        t1.start();

        try {
            String s = futureTask.get();
            System.out.println(s);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
